<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/common/taglibs.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
            <title>地址管理</title>
            <link rel="stylesheet" href="${ctx }/css/mui.min.css"/>
            <link rel="stylesheet" href="${ctx }/css/dw-wx-login.css"/>
            <link rel="stylesheet" href="${ctx }/css/dw-wx-login-font.css"/>
            <script src="${ctx }/js/plugs/mui/jquery-1.8.3.min.js" type="text/javascript"></script>
            <script src="${ctx }/js/plugs/mui/mui.min.js" type="text/javascript"></script>
            <script>
                function newclick() {
                    //check一下
                    var name = $("#name").val();

                    if (name==null||name.length <1) {

                        mui.toast('收件人不为空', {duration: 'long', type: 'div'});
                        $('#name').focus();
                        return false;
                    }
                    var zipcode = $("#zipcode").val();
                    if (zipcode == null) {
                        mui.toast('邮编不为空', {duration: 'long', type: 'div'});
                        $('#zipcode').focus();
                        return false;
                    }
                    var phone = $("#phone").val();
                    if (phone == null||phone.length<1) {
                        mui.toast('手机号不能为空', {duration: 'long', type: 'div'});
                        $('#phone').focus();
                        return false;
                    }
                    var address = $("#address").val();
                    if (address == null) {
                        mui.toast('地址不能为空', {duration: 'long', type: 'div'});
                        $('#address').focus();
                        return false;
                    }
                    var url = $("#wxUserForm").attr("action");
                    $.ajax({
                        url: url,
                        type: "POST",
                        async: false,
                        data: $('#wxUserForm').serialize(),
                        success: function (data) {

                            mui.toast('保存成功', {duration: 'long', type: 'div'});
                           <%--if("0"==${flag})--%>
                           <%--{--%>
                               window.open("${ctx }/wexin/Presentcontact.do?flag=${flag}");
                           <%--}--%>

                        },
                        error: function (e) {
                            mui.toast('保存失败', {duration: 'long', type: 'div'});
                        }
                    });

                }

                function mySurvey() {
                    window.location.href = "${ctx }/wexin/mySurvey.do";
                }
            </script>
        </head>
        <body style="background: url(../images/bg.jpg);">
            <header class="mui-bar mui-bar-nav" style="padding-right: 15px;">

                <a class=" mui-icon mui-icon-contact mui-pull-right" href="${ctx }/wexin/myInfo.do"></a>
                <a class=" mui-icon mui-icon-starhalf mui-pull-right" href="${ctx }/wexin/myPrize.do"></a>
                <a class=" mui-icon mui-icon-compose mui-pull-right" href="${ctx }/wexin/mySurvey.do"></a>
                <h1 class="mui-title"></h1>
            </header>

            <div class="mui-content">
                <form class="mui-input-group" id="wxUserForm" action="${ctx }/wexin/saveMyInfo.do" method="post">
                    <input type="hidden" name="flag" value="${flag}"/>
                    <div class="mui-input-row">

                        <label><p style="color: red;margin: 0px;float: left;padding: 0px;">*</p>收件人</label>
                        <input type="text" class="mui-input-clear" name="name" placeholder="请输入收件人" value="${entity.name }"
                               id="name">
                    </div>

                    <div class="mui-input-row">
                        <label><p style="color: red;margin: 0px;float: left;padding: 0px;">*</p>联系电话</label>
                        <input type="text" class="mui-input-clear" name="phone" placeholder="联系电话" value="${entity.phone }"
                               id="phone">
                    </div>
                    <div class="mui-input-row">
                        <label>&nbsp;邮编</label>
                        <input type="text" class="mui-input-clear" name="zipcode" placeholder="请输入邮编" value="${entity.zipcode }"
                               id="zipcode">
                    </div>
                    <div class="mui-input-row">
                        <label>&nbsp;地址</label>
                        <input type="text" class="mui-input-clear" name="address" placeholder="地址" value="${entity.address }"
                               id="address">
                    </div>
                    <div class="mui-button-row">
                        <button type="button" class="mui-btn mui-btn-primary" onclick="newclick()">确认</button>
                        <button type="button" class="mui-btn mui-btn-danger" onclick="mySurvey()">取消</button>
                    </div>
                </form>
            </div>
            <div class="footer">
                Powered by ACBSP China
            </div>
        </body>
    </html>
